import request from '@/utils/request'

/**
 *
 * @param {*} params  {page, pagesize}
 * @returns
 */
export const getRoles = (params) => request.get('/sys/role', { params })

/**
 *
 * @returns 已启用的角色列表
 */
export const getRolesEnabled = () => request.get('/sys/role/list/enabled')

/**
 * 给员工分配角色
 * @param {*} data
 * @returns
 */
export const assignRole = (data) => request.put('/sys/user/assignRoles', data)

/**
 *  添加角色
 * @param {*} data {name, description, state}
 * @returns
 */
export const addRole = (data) => request.post('/sys/role', data)

/**
 * 更新角色
 * @param {*} data  {id, name, description, state}
 * @returns
 */
export const updateRole = (data) => request.put('/sys/role/' + data.id, data)

/**
 * 功能: 删除角色
 * @param {number} id : 要删除的角色的id
 * @returns 调用接口的结果
 */
export const delRole = id => request.delete('/sys/role/' + id)

export const getPermissById = id => request.get('/sys/role/' + id)
